7Z压缩解压缩.zip
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using System.Collections;using System.IO;using Microsoft.Win32;using System.Windows.Forms;namespace _7Z压缩解压缩{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } /// <summary> /// 压缩 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, RoutedEventArgs e) { string st0 = @"C:\Users\JimmyBright\Desktop\测试图片\测试图片\1"; string st1 = @"C:\Users\JimmyBright\Desktop\测试图片\测试图片\2"; string st2 = @"C:\Users\JimmyBright\Desktop\测试图片\测试图片\3"; string st3 = @"C:\Users\JimmyBright\Desktop\测试图片\测试图片\4"; ArrayList myList = new ArrayList() { st0, st1, st2, st3 }; System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.FilterIndex = 1; sfd.Filter = "保存离线资源包:(*.7z)|*.7z"; sfd.FilterIndex = 1; sfd.Title = "保存离线资源包"; sfd.RestoreDirectory = true; sfd.FileName = "eDemo离线资源包"; sfd.ShowDialog(); if (sfd.FileName != "eDemo离线资源包") { ZipHelper.WinrarZipFile(myList, sfd.FileName); } } /// <summary> /// 解压缩 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, RoutedEventArgs e) { string st1 = @"C:\Users\JimmyBright\Desktop"; System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Filter = "eDemo离线资源包:(*.7z)|*.7z"; dialog.FilterIndex = 1; dialog.RestoreDirectory = true; dialog.Title = "迁入离线资源包"; dialog.FileName = "选择离线资源包"; dialog.Multiselect = false; dialog.ShowDialog(); if (dialog.FileName != "选择离线资源包") { ZipHelper.WinrarUnZipPath(dialog.FileName, st1); } } }}
评论